import request from "@/utils/request";

/**
 * 获取包材订单列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getPacketOrderList(params = {}){
  return request({
    url: '/packetOrders/getPacketOrderList',
    method: 'get',
    params,
  })
}
/**
 * 获取子账户列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getChildUserList(params = {}){
  return request({
    url: '/packetOrders/getChildUserList',
    method: 'get',
    params,
  })
}


/**
 * 获取包材订单列表数量
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getPacketOrderListNum(params = {}) {
  return request({
    url: '/packetOrders/getPacketOrderListNum',
    method: 'get',
    params,
  })
}

export function getPacketOrderInfo(packetOrderId) {
  return request({
    url: '/packetOrders/getPacketOrderInfo/' + packetOrderId,
    method: 'get',
  })
}

export function cancelPacketOrder(packetOrderId) {
  return request({
    url: '/packetOrders/cancelPacketOrder/' + packetOrderId,
    method: 'delete',
  })
}

export function getMultiRate(packetOrderData) {
  return request({
    url: '/packetOrders/getMultiRate',
    method: 'post',
    data: packetOrderData,
    throwCatch: true,
  })
}

export function getPacketOrderExpectInfo(packetOrderData) {
  return request({
    url: '/packetOrders/getPacketOrderExpectInfo',
    method: 'post',
    data: packetOrderData,
    throwCatch: true,
  })
}

export function savePacketOrder(packetOrderData) {
  return request({
    url: '/packetOrders/savePacketOrder',
    method: 'post',
    data: packetOrderData,
    throwCatch: true,
  })
}

export function checkPacketOrderRepeat(packetOrderData) {
  return request({
    url: '/packetOrders/checkPacketOrderRepeat',
    method: 'post',
    data: packetOrderData,
    throwCatch: true,
  })
}

export function getUSCitiesData() {
  return request({
    url: '/packetOrders/getUSCitiesData',
    method: 'get',
  })
}

export function getCitiesData(params) {
  return request({
    url: '/packetOrders/getCitiesData',
    method: 'get',
    params,
  })
}

/**
 * 获取模板数据(小包订单)
 * @returns {Promise<unknown>}
 */
export function getBatchUploadPacketOrderTemplate(){
  return request({
    url: '/packetOrders/getBatchUploadPacketOrderTemplate',
    method: "get",
    responseType: "blob", // 需要加上
    isNotJson: true,
    timeout: 60000 * 5, // 1分钟
    handleError: true,
  })
}

/**
 * 查询批量上传列表(订单)
 * @param paramsData
 * @returns {Promise | Promise<unknown>}
 */
export function getBatchUploadPacketOrderList(paramsData) {
  return request({
    url: "/packetOrders/getBatchUploadPacketOrderList",
    method: "get",
    data: paramsData
  })
}

/**
 * 查询批量上传的错误信息(订单)
 * @param id
 * @param paramsData
 * @returns {Promise | Promise<unknown>}
 */
export function getBatchUploadPacketOrderErrorData(paramsData, id) {
  return request({
    url: "/packetOrders/getBatchUploadPacketOrderErrorData/" + id,
    method: "get",
    data: paramsData
  })
}

